package com.askinhand.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.askinhand.bean.AudioAnswer;
import com.askinhand.bean.PictureAnswer;
import com.askinhand.dao.impl.PictureAnswerDAO;
import com.askinhand.service.IPictureAnswerService;

public class PictureAnswerService implements IPictureAnswerService{

	PictureAnswerDAO pictureAnswerDAO;

	public PictureAnswerDAO getPictureAnswerDAO() {
		return pictureAnswerDAO;
	}

	public void setPictureAnswerDAO(PictureAnswerDAO pictureAnswerDAO) {
		this.pictureAnswerDAO = pictureAnswerDAO;
	}
	

	public ArrayList personalAnswerReturn(String uid) {
		// TODO Auto-generated method stub
		ArrayList<PictureAnswer> pic=new ArrayList<PictureAnswer>();

		List li=pictureAnswerDAO.findByUid(Integer.parseInt(uid));
		 Iterator it=li.iterator();
		while(it.hasNext()){
			PictureAnswer picanswer=(PictureAnswer)it.next();
			pic.add(picanswer);
			
		}
	
		return pic;
	}


	public String rate(String answerid, String isGood, String feedback) {
		// TODO Auto-generated method stub
		PictureAnswer picanswer=pictureAnswerDAO.findById(Integer.parseInt(answerid));
		picanswer.setFeedback(feedback);
		picanswer.setIsGood(isGood);
		pictureAnswerDAO.update(picanswer);

		return "success";
	}
}
